package com.situ.vivamarket.service.front.impl;

import com.situ.vivamarket.dao.AddressDao;
import com.situ.vivamarket.dao.MemberAddrDao;
import com.situ.vivamarket.model.Address;
import com.situ.vivamarket.model.front.MemberAddress;
import com.situ.vivamarket.service.front.MemberAddrService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MemAddrServiceImpl implements MemberAddrService {
    private MemberAddrDao memberAddrDao;
    private AddressDao addressDao;

    @Autowired
    public void setMemberAddrDao(MemberAddrDao memberAddrDao) {
        this.memberAddrDao = memberAddrDao;
    }
    @Autowired
    public void setAddressDao(AddressDao addressDao) {
        this.addressDao = addressDao;
    }

    //    查询会员地址
    @Override
    public List<MemberAddress> findByMemberId(Integer memberId) {
        return memberAddrDao.findByMemberId(memberId);
    }
//        新增会员地址
    @Override
    public boolean add(MemberAddress ma) {
        return memberAddrDao.insert(ma)>0;
    }
//        根据id，删除会员地址
    @Override
    public boolean deleteById(Integer id) {
        return memberAddrDao.deleteById(id)>0;
    }
    //  根据父id查找地址，省市区等，省的父亲id是null
    @Override
    public List<Address> findAddrByPatentId(Integer parentId) {
        return addressDao.findAddrByParentId(parentId);
    }
}
